﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using Indeco.G24.Entities;
using Indeco.G24.Data;

#endregion

namespace Indeco.G24.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="NhaCungCapProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class NhaCungCapProviderBaseCore : EntityProviderBase<Indeco.G24.Entities.NhaCungCap, Indeco.G24.Entities.NhaCungCapKey>
	{		
		#region Get from Many To Many Relationship Functions
		#region GetByIDNguoiDungFromNguoiDungNhaCungCap
		
		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungNhaCungCap table. Table tb_NhaCungCap is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungNhaCungCap table.
		/// </summary>
		/// <param name="iDNguoiDung"></param>
		/// <returns>Returns a typed collection of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNguoiDungFromNguoiDungNhaCungCap(System.Guid iDNguoiDung)
		{
			int count = -1;
			return GetByIDNguoiDungFromNguoiDungNhaCungCap(null,iDNguoiDung, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets Indeco.G24.Entities.NhaCungCap objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungNhaCungCap table. Table tb_NhaCungCap is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungNhaCungCap table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDNguoiDung"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNguoiDungFromNguoiDungNhaCungCap(System.Guid iDNguoiDung, int start, int pageLength)
		{
			int count = -1;
			return GetByIDNguoiDungFromNguoiDungNhaCungCap(null, iDNguoiDung, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungNhaCungCap table. Table tb_NhaCungCap is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungNhaCungCap table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNguoiDung"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNguoiDungFromNguoiDungNhaCungCap(TransactionManager transactionManager, System.Guid iDNguoiDung)
		{
			int count = -1;
			return GetByIDNguoiDungFromNguoiDungNhaCungCap(transactionManager, iDNguoiDung, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungNhaCungCap table. Table tb_NhaCungCap is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungNhaCungCap table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNguoiDung"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNguoiDungFromNguoiDungNhaCungCap(TransactionManager transactionManager, System.Guid iDNguoiDung,int start, int pageLength)
		{
			int count = -1;
			return GetByIDNguoiDungFromNguoiDungNhaCungCap(transactionManager, iDNguoiDung, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungNhaCungCap table. Table tb_NhaCungCap is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungNhaCungCap table.
		/// </summary>
		/// <param name="iDNguoiDung"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNguoiDungFromNguoiDungNhaCungCap(System.Guid iDNguoiDung,int start, int pageLength, out int count)
		{
			
			return GetByIDNguoiDungFromNguoiDungNhaCungCap(null, iDNguoiDung, start, pageLength, out count);
		}


		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungNhaCungCap table. Table tb_NhaCungCap is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungNhaCungCap table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="iDNguoiDung"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public abstract TList<NhaCungCap> GetByIDNguoiDungFromNguoiDungNhaCungCap(TransactionManager transactionManager,System.Guid iDNguoiDung, int start, int pageLength, out int count);
		
		#endregion GetByIDNguoiDungFromNguoiDungNhaCungCap
		
		#region GetByIDDiaBanFromNhaCungCapDiaBan
		
		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapDiaBan table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="iDDiaBan"></param>
		/// <returns>Returns a typed collection of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapDiaBan(System.Guid iDDiaBan)
		{
			int count = -1;
			return GetByIDDiaBanFromNhaCungCapDiaBan(null,iDDiaBan, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets Indeco.G24.Entities.NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapDiaBan table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDDiaBan"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapDiaBan(System.Guid iDDiaBan, int start, int pageLength)
		{
			int count = -1;
			return GetByIDDiaBanFromNhaCungCapDiaBan(null, iDDiaBan, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapDiaBan table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDDiaBan"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapDiaBan(TransactionManager transactionManager, System.Guid iDDiaBan)
		{
			int count = -1;
			return GetByIDDiaBanFromNhaCungCapDiaBan(transactionManager, iDDiaBan, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapDiaBan table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDDiaBan"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapDiaBan(TransactionManager transactionManager, System.Guid iDDiaBan,int start, int pageLength)
		{
			int count = -1;
			return GetByIDDiaBanFromNhaCungCapDiaBan(transactionManager, iDDiaBan, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapDiaBan table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="iDDiaBan"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapDiaBan(System.Guid iDDiaBan,int start, int pageLength, out int count)
		{
			
			return GetByIDDiaBanFromNhaCungCapDiaBan(null, iDDiaBan, start, pageLength, out count);
		}


		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapDiaBan table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="iDDiaBan"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public abstract TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapDiaBan(TransactionManager transactionManager,System.Guid iDDiaBan, int start, int pageLength, out int count);
		
		#endregion GetByIDDiaBanFromNhaCungCapDiaBan
		
		#region GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc
		
		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="iDDiaBan"></param>
		/// <returns>Returns a typed collection of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(System.Guid iDDiaBan)
		{
			int count = -1;
			return GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(null,iDDiaBan, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets Indeco.G24.Entities.NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDDiaBan"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(System.Guid iDDiaBan, int start, int pageLength)
		{
			int count = -1;
			return GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(null, iDDiaBan, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDDiaBan"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager, System.Guid iDDiaBan)
		{
			int count = -1;
			return GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(transactionManager, iDDiaBan, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDDiaBan"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager, System.Guid iDDiaBan,int start, int pageLength)
		{
			int count = -1;
			return GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(transactionManager, iDDiaBan, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="iDDiaBan"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(System.Guid iDDiaBan,int start, int pageLength, out int count)
		{
			
			return GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(null, iDDiaBan, start, pageLength, out count);
		}


		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_DiaBan in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_DiaBan
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="iDDiaBan"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public abstract TList<NhaCungCap> GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager,System.Guid iDDiaBan, int start, int pageLength, out int count);
		
		#endregion GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc
		
		#region GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc
		
		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <returns>Returns a typed collection of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(System.Guid iDSanPhamDanhMuc)
		{
			int count = -1;
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(null,iDSanPhamDanhMuc, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets Indeco.G24.Entities.NhaCungCap objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(System.Guid iDSanPhamDanhMuc, int start, int pageLength)
		{
			int count = -1;
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(null, iDSanPhamDanhMuc, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager, System.Guid iDSanPhamDanhMuc)
		{
			int count = -1;
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(transactionManager, iDSanPhamDanhMuc, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager, System.Guid iDSanPhamDanhMuc,int start, int pageLength)
		{
			int count = -1;
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(transactionManager, iDSanPhamDanhMuc, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(System.Guid iDSanPhamDanhMuc,int start, int pageLength, out int count)
		{
			
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(null, iDSanPhamDanhMuc, start, pageLength, out count);
		}


		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_NhaCungCap is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public abstract TList<NhaCungCap> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager,System.Guid iDSanPhamDanhMuc, int start, int pageLength, out int count);
		
		#endregion GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc
		
		#region GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh
		
		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_NganhNgheKinhDoanh in the
		///		tb_NhaCungCapNganhNgheKinhDoanh table. Table tb_NhaCungCap is related to table tb_NganhNgheKinhDoanh
		///		through the (M:N) relationship defined in the tb_NhaCungCapNganhNgheKinhDoanh table.
		/// </summary>
		/// <param name="iDNganhNgheKinhDoanh"></param>
		/// <returns>Returns a typed collection of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(System.Guid iDNganhNgheKinhDoanh)
		{
			int count = -1;
			return GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(null,iDNganhNgheKinhDoanh, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets Indeco.G24.Entities.NhaCungCap objects from the datasource by ID_NganhNgheKinhDoanh in the
		///		tb_NhaCungCapNganhNgheKinhDoanh table. Table tb_NhaCungCap is related to table tb_NganhNgheKinhDoanh
		///		through the (M:N) relationship defined in the tb_NhaCungCapNganhNgheKinhDoanh table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDNganhNgheKinhDoanh"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(System.Guid iDNganhNgheKinhDoanh, int start, int pageLength)
		{
			int count = -1;
			return GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(null, iDNganhNgheKinhDoanh, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_NganhNgheKinhDoanh in the
		///		tb_NhaCungCapNganhNgheKinhDoanh table. Table tb_NhaCungCap is related to table tb_NganhNgheKinhDoanh
		///		through the (M:N) relationship defined in the tb_NhaCungCapNganhNgheKinhDoanh table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNganhNgheKinhDoanh"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(TransactionManager transactionManager, System.Guid iDNganhNgheKinhDoanh)
		{
			int count = -1;
			return GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(transactionManager, iDNganhNgheKinhDoanh, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_NganhNgheKinhDoanh in the
		///		tb_NhaCungCapNganhNgheKinhDoanh table. Table tb_NhaCungCap is related to table tb_NganhNgheKinhDoanh
		///		through the (M:N) relationship defined in the tb_NhaCungCapNganhNgheKinhDoanh table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNganhNgheKinhDoanh"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(TransactionManager transactionManager, System.Guid iDNganhNgheKinhDoanh,int start, int pageLength)
		{
			int count = -1;
			return GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(transactionManager, iDNganhNgheKinhDoanh, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets NhaCungCap objects from the datasource by ID_NganhNgheKinhDoanh in the
		///		tb_NhaCungCapNganhNgheKinhDoanh table. Table tb_NhaCungCap is related to table tb_NganhNgheKinhDoanh
		///		through the (M:N) relationship defined in the tb_NhaCungCapNganhNgheKinhDoanh table.
		/// </summary>
		/// <param name="iDNganhNgheKinhDoanh"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_NhaCungCap objects.</returns>
		public TList<NhaCungCap> GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(System.Guid iDNganhNgheKinhDoanh,int start, int pageLength, out int count)
		{
			
			return GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(null, iDNganhNgheKinhDoanh, start, pageLength, out count);
		}


		/// <summary>
		///		Gets tb_NhaCungCap objects from the datasource by ID_NganhNgheKinhDoanh in the
		///		tb_NhaCungCapNganhNgheKinhDoanh table. Table tb_NhaCungCap is related to table tb_NganhNgheKinhDoanh
		///		through the (M:N) relationship defined in the tb_NhaCungCapNganhNgheKinhDoanh table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="iDNganhNgheKinhDoanh"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of NhaCungCap objects.</returns>
		public abstract TList<NhaCungCap> GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh(TransactionManager transactionManager,System.Guid iDNganhNgheKinhDoanh, int start, int pageLength, out int count);
		
		#endregion GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh
		
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, Indeco.G24.Entities.NhaCungCapKey key)
		{
			return Delete(transactionManager, key.IDNhaCungCap);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="iDNhaCungCap">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Guid iDNhaCungCap)
		{
			return Delete(null, iDNhaCungCap);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNhaCungCap">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Guid iDNhaCungCap);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override Indeco.G24.Entities.NhaCungCap Get(TransactionManager transactionManager, Indeco.G24.Entities.NhaCungCapKey key, int start, int pageLength)
		{
			return GetByIDNhaCungCap(transactionManager, key.IDNhaCungCap, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_tb_NhaCungCap index.
		/// </summary>
		/// <param name="iDNhaCungCap"></param>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByIDNhaCungCap(System.Guid iDNhaCungCap)
		{
			int count = -1;
			return GetByIDNhaCungCap(null,iDNhaCungCap, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_NhaCungCap index.
		/// </summary>
		/// <param name="iDNhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByIDNhaCungCap(System.Guid iDNhaCungCap, int start, int pageLength)
		{
			int count = -1;
			return GetByIDNhaCungCap(null, iDNhaCungCap, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_NhaCungCap index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNhaCungCap"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByIDNhaCungCap(TransactionManager transactionManager, System.Guid iDNhaCungCap)
		{
			int count = -1;
			return GetByIDNhaCungCap(transactionManager, iDNhaCungCap, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_NhaCungCap index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByIDNhaCungCap(TransactionManager transactionManager, System.Guid iDNhaCungCap, int start, int pageLength)
		{
			int count = -1;
			return GetByIDNhaCungCap(transactionManager, iDNhaCungCap, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_NhaCungCap index.
		/// </summary>
		/// <param name="iDNhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByIDNhaCungCap(System.Guid iDNhaCungCap, int start, int pageLength, out int count)
		{
			return GetByIDNhaCungCap(null, iDNhaCungCap, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_NhaCungCap index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public abstract Indeco.G24.Entities.NhaCungCap GetByIDNhaCungCap(TransactionManager transactionManager, System.Guid iDNhaCungCap, int start, int pageLength, out int count);
						
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key IX_tb_NhaCungCap index.
		/// </summary>
		/// <param name="nhaCungCap"></param>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByNhaCungCap(System.String nhaCungCap)
		{
			int count = -1;
			return GetByNhaCungCap(null,nhaCungCap, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_tb_NhaCungCap index.
		/// </summary>
		/// <param name="nhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByNhaCungCap(System.String nhaCungCap, int start, int pageLength)
		{
			int count = -1;
			return GetByNhaCungCap(null, nhaCungCap, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_tb_NhaCungCap index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="nhaCungCap"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByNhaCungCap(TransactionManager transactionManager, System.String nhaCungCap)
		{
			int count = -1;
			return GetByNhaCungCap(transactionManager, nhaCungCap, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_tb_NhaCungCap index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="nhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByNhaCungCap(TransactionManager transactionManager, System.String nhaCungCap, int start, int pageLength)
		{
			int count = -1;
			return GetByNhaCungCap(transactionManager, nhaCungCap, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_tb_NhaCungCap index.
		/// </summary>
		/// <param name="nhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public Indeco.G24.Entities.NhaCungCap GetByNhaCungCap(System.String nhaCungCap, int start, int pageLength, out int count)
		{
			return GetByNhaCungCap(null, nhaCungCap, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_tb_NhaCungCap index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="nhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.NhaCungCap"/> class.</returns>
		public abstract Indeco.G24.Entities.NhaCungCap GetByNhaCungCap(TransactionManager transactionManager, System.String nhaCungCap, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a Indeco.G24.Entities.TList&lt;NhaCungCap&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="Indeco.G24.Entities.TList&lt;NhaCungCap&gt;"/></returns>
		public static Indeco.G24.Entities.TList<NhaCungCap> Fill(IDataReader reader, Indeco.G24.Entities.TList<NhaCungCap> rows, int start, int pageLength)
		{
		// advance to the starting row
		for (int i = 0; i < start; i++)
		{
			if (!reader.Read())
			return rows; // not enough rows, just return
		}
		for (int i = 0; i < pageLength; i++)
		{
			if (!reader.Read())
			break; // we are done
			string key = null;
			
			Indeco.G24.Entities.NhaCungCap c = null;
			if (DataRepository.Provider.UseEntityFactory)
			{
			key = new System.Text.StringBuilder("NhaCungCap")
			.Append("|").Append((reader.IsDBNull(((int)Indeco.G24.Entities.NhaCungCapColumn.IDNhaCungCap - 1))?Guid.NewGuid():(System.Guid)reader[((int)Indeco.G24.Entities.NhaCungCapColumn.IDNhaCungCap - 1)]).ToString()).ToString();
			c = EntityManager.LocateOrCreate<NhaCungCap>(
			key.ToString(), // EntityTrackingKey
			"NhaCungCap",  //Creational Type
			DataRepository.Provider.EntityCreationalFactoryType,  //Factory used to create entity
			DataRepository.Provider.EnableEntityTracking); // Track this entity?
			}
			else
			{
			c = new Indeco.G24.Entities.NhaCungCap();
			}
			
			if (!DataRepository.Provider.EnableEntityTracking ||
			c.EntityState == EntityState.Added ||
			(DataRepository.Provider.EnableEntityTracking &&
			((DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
			(DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.DiscardChanges && (c.EntityState == EntityState.Unchanged ||
								c.EntityState == EntityState.Changed)))))
						{
			c.SuppressEntityEvents = true;
			c.IDNhaCungCap = (System.Guid)reader["ID_NhaCungCap"];
			c.OriginalIDNhaCungCap = c.IDNhaCungCap;
			c.NhaCungCap = (System.String)reader["NhaCungCap"];
			c.Ten = (System.String)reader["Ten"];
			c.MoTa = reader.IsDBNull(reader.GetOrdinal("MoTa")) ? null : (System.String)reader["MoTa"];
			c.HinhMinhHoa = reader.IsDBNull(reader.GetOrdinal("HinhMinhHoa")) ? null : (System.String)reader["HinhMinhHoa"];
			c.KhauHieu = reader.IsDBNull(reader.GetOrdinal("KhauHieu")) ? null : (System.String)reader["KhauHieu"];
			c.ChungThuc = (System.Boolean)reader["ChungThuc"];
			c.MaKichHoat = reader.IsDBNull(reader.GetOrdinal("MaKichHoat")) ? null : (System.String)reader["MaKichHoat"];
			c.KichHoat = (System.Boolean)reader["KichHoat"];
			c.CamHoatDong = (System.Boolean)reader["CamHoatDong"];
			c.Xoa = (System.Boolean)reader["Xoa"];
			c.DiaChi = reader.IsDBNull(reader.GetOrdinal("DiaChi")) ? null : (System.String)reader["DiaChi"];
			c.DienThoai = reader.IsDBNull(reader.GetOrdinal("DienThoai")) ? null : (System.String)reader["DienThoai"];
			c.Fax = reader.IsDBNull(reader.GetOrdinal("Fax")) ? null : (System.String)reader["Fax"];
			c.Website = reader.IsDBNull(reader.GetOrdinal("Website")) ? null : (System.String)reader["Website"];
			c.Email = (System.String)reader["Email"];
			c.Vitri = (System.Int64)reader["Vitri"];
			c.ThoiDiemTruyCap = (System.DateTime)reader["ThoiDiemTruyCap"];
			c.ThoiDiemThoat = (System.DateTime)reader["ThoiDiemThoat"];
			c.ThoiDiemCapNhat = (System.DateTime)reader["ThoiDiemCapNhat"];
			c.ThoiDiemChinhSua = (System.DateTime)reader["ThoiDiemChinhSua"];
			c.EntityTrackingKey = key;
			c.AcceptChanges();
			c.SuppressEntityEvents = false;
			}
			rows.Add(c);
		}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="Indeco.G24.Entities.NhaCungCap"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="Indeco.G24.Entities.NhaCungCap"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, Indeco.G24.Entities.NhaCungCap entity)
		{
			if (!reader.Read()) return;
			
			entity.IDNhaCungCap = (System.Guid)reader["ID_NhaCungCap"];
			entity.OriginalIDNhaCungCap = (System.Guid)reader["ID_NhaCungCap"];
			entity.NhaCungCap = (System.String)reader["NhaCungCap"];
			entity.Ten = (System.String)reader["Ten"];
			entity.MoTa = reader.IsDBNull(reader.GetOrdinal("MoTa")) ? null : (System.String)reader["MoTa"];
			entity.HinhMinhHoa = reader.IsDBNull(reader.GetOrdinal("HinhMinhHoa")) ? null : (System.String)reader["HinhMinhHoa"];
			entity.KhauHieu = reader.IsDBNull(reader.GetOrdinal("KhauHieu")) ? null : (System.String)reader["KhauHieu"];
			entity.ChungThuc = (System.Boolean)reader["ChungThuc"];
			entity.MaKichHoat = reader.IsDBNull(reader.GetOrdinal("MaKichHoat")) ? null : (System.String)reader["MaKichHoat"];
			entity.KichHoat = (System.Boolean)reader["KichHoat"];
			entity.CamHoatDong = (System.Boolean)reader["CamHoatDong"];
			entity.Xoa = (System.Boolean)reader["Xoa"];
			entity.DiaChi = reader.IsDBNull(reader.GetOrdinal("DiaChi")) ? null : (System.String)reader["DiaChi"];
			entity.DienThoai = reader.IsDBNull(reader.GetOrdinal("DienThoai")) ? null : (System.String)reader["DienThoai"];
			entity.Fax = reader.IsDBNull(reader.GetOrdinal("Fax")) ? null : (System.String)reader["Fax"];
			entity.Website = reader.IsDBNull(reader.GetOrdinal("Website")) ? null : (System.String)reader["Website"];
			entity.Email = (System.String)reader["Email"];
			entity.Vitri = (System.Int64)reader["Vitri"];
			entity.ThoiDiemTruyCap = (System.DateTime)reader["ThoiDiemTruyCap"];
			entity.ThoiDiemThoat = (System.DateTime)reader["ThoiDiemThoat"];
			entity.ThoiDiemCapNhat = (System.DateTime)reader["ThoiDiemCapNhat"];
			entity.ThoiDiemChinhSua = (System.DateTime)reader["ThoiDiemChinhSua"];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="Indeco.G24.Entities.NhaCungCap"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="Indeco.G24.Entities.NhaCungCap"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, Indeco.G24.Entities.NhaCungCap entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IDNhaCungCap = (System.Guid)dataRow["ID_NhaCungCap"];
			entity.OriginalIDNhaCungCap = (System.Guid)dataRow["ID_NhaCungCap"];
			entity.NhaCungCap = (System.String)dataRow["NhaCungCap"];
			entity.Ten = (System.String)dataRow["Ten"];
			entity.MoTa = Convert.IsDBNull(dataRow["MoTa"]) ? null : (System.String)dataRow["MoTa"];
			entity.HinhMinhHoa = Convert.IsDBNull(dataRow["HinhMinhHoa"]) ? null : (System.String)dataRow["HinhMinhHoa"];
			entity.KhauHieu = Convert.IsDBNull(dataRow["KhauHieu"]) ? null : (System.String)dataRow["KhauHieu"];
			entity.ChungThuc = (System.Boolean)dataRow["ChungThuc"];
			entity.MaKichHoat = Convert.IsDBNull(dataRow["MaKichHoat"]) ? null : (System.String)dataRow["MaKichHoat"];
			entity.KichHoat = (System.Boolean)dataRow["KichHoat"];
			entity.CamHoatDong = (System.Boolean)dataRow["CamHoatDong"];
			entity.Xoa = (System.Boolean)dataRow["Xoa"];
			entity.DiaChi = Convert.IsDBNull(dataRow["DiaChi"]) ? null : (System.String)dataRow["DiaChi"];
			entity.DienThoai = Convert.IsDBNull(dataRow["DienThoai"]) ? null : (System.String)dataRow["DienThoai"];
			entity.Fax = Convert.IsDBNull(dataRow["Fax"]) ? null : (System.String)dataRow["Fax"];
			entity.Website = Convert.IsDBNull(dataRow["Website"]) ? null : (System.String)dataRow["Website"];
			entity.Email = (System.String)dataRow["Email"];
			entity.Vitri = (System.Int64)dataRow["Vitri"];
			entity.ThoiDiemTruyCap = (System.DateTime)dataRow["ThoiDiemTruyCap"];
			entity.ThoiDiemThoat = (System.DateTime)dataRow["ThoiDiemThoat"];
			entity.ThoiDiemCapNhat = (System.DateTime)dataRow["ThoiDiemCapNhat"];
			entity.ThoiDiemChinhSua = (System.DateTime)dataRow["ThoiDiemChinhSua"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="Indeco.G24.Entities.NhaCungCap"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">Indeco.G24.Entities.NhaCungCap Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		internal override void DeepLoad(TransactionManager transactionManager, Indeco.G24.Entities.NhaCungCap entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByIDNhaCungCap methods when available
			
			#region NhaCungCapSanPhamDanhMucCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NhaCungCapSanPhamDanhMuc>|NhaCungCapSanPhamDanhMucCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NhaCungCapSanPhamDanhMucCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NhaCungCapSanPhamDanhMucCollection = DataRepository.NhaCungCapSanPhamDanhMucProvider.GetByIDNhaCungCap(transactionManager, entity.IDNhaCungCap);

				if (deep && entity.NhaCungCapSanPhamDanhMucCollection.Count > 0)
				{
					deepHandles.Add("NhaCungCapSanPhamDanhMucCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NhaCungCapSanPhamDanhMuc>) DataRepository.NhaCungCapSanPhamDanhMucProvider.DeepLoad,
						new object[] { transactionManager, entity.NhaCungCapSanPhamDanhMucCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region BangGiaSanPhamCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<BangGiaSanPham>|BangGiaSanPhamCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'BangGiaSanPhamCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.BangGiaSanPhamCollection = DataRepository.BangGiaSanPhamProvider.GetByIDNhaCungCap(transactionManager, entity.IDNhaCungCap);

				if (deep && entity.BangGiaSanPhamCollection.Count > 0)
				{
					deepHandles.Add("BangGiaSanPhamCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<BangGiaSanPham>) DataRepository.BangGiaSanPhamProvider.DeepLoad,
						new object[] { transactionManager, entity.BangGiaSanPhamCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region SanPhamCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<SanPham>|SanPhamCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'SanPhamCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.SanPhamCollection = DataRepository.SanPhamProvider.GetByNhaCungCap(transactionManager, entity.NhaCungCap);

				if (deep && entity.SanPhamCollection.Count > 0)
				{
					deepHandles.Add("SanPhamCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<SanPham>) DataRepository.SanPhamProvider.DeepLoad,
						new object[] { transactionManager, entity.SanPhamCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region NhaCungCapLienHeCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NhaCungCapLienHe>|NhaCungCapLienHeCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NhaCungCapLienHeCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NhaCungCapLienHeCollection = DataRepository.NhaCungCapLienHeProvider.GetByIDNhaCungCap(transactionManager, entity.IDNhaCungCap);

				if (deep && entity.NhaCungCapLienHeCollection.Count > 0)
				{
					deepHandles.Add("NhaCungCapLienHeCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NhaCungCapLienHe>) DataRepository.NhaCungCapLienHeProvider.DeepLoad,
						new object[] { transactionManager, entity.NhaCungCapLienHeCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region NhaCungCapCauHinh
			// RelationshipType.OneToOne
			if (CanDeepLoad(entity, "NhaCungCapCauHinh|NhaCungCapCauHinh", deepLoadType, innerList))
			{
				entity.NhaCungCapCauHinh = DataRepository.NhaCungCapCauHinhProvider.GetByIDNhaCungCap(transactionManager, entity.IDNhaCungCap);
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NhaCungCapCauHinh' loaded. key " + entity.EntityTrackingKey);
				#endif 

				if (deep && entity.NhaCungCapCauHinh != null)
				{
					deepHandles.Add("NhaCungCapCauHinh",
						new KeyValuePair<Delegate, object>((DeepLoadSingleHandle< NhaCungCapCauHinh >) DataRepository.NhaCungCapCauHinhProvider.DeepLoad,
						new object[] { transactionManager, entity.NhaCungCapCauHinh, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion 
			
			
			
			#region DiaBanCollection_From_NhaCungCapSanPhamDanhMuc
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<DiaBan>|DiaBanCollection_From_NhaCungCapSanPhamDanhMuc", deepLoadType, innerList))
			{
				entity.DiaBanCollection_From_NhaCungCapSanPhamDanhMuc = DataRepository.DiaBanProvider.GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(transactionManager, entity.IDNhaCungCap);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'DiaBanCollection_From_NhaCungCapSanPhamDanhMuc' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.DiaBanCollection_From_NhaCungCapSanPhamDanhMuc != null)
				{
					deepHandles.Add("DiaBanCollection_From_NhaCungCapSanPhamDanhMuc",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< DiaBan >) DataRepository.DiaBanProvider.DeepLoad,
						new object[] { transactionManager, entity.DiaBanCollection_From_NhaCungCapSanPhamDanhMuc, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region NhaCungCapNganhNgheKinhDoanhCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NhaCungCapNganhNgheKinhDoanh>|NhaCungCapNganhNgheKinhDoanhCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NhaCungCapNganhNgheKinhDoanhCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NhaCungCapNganhNgheKinhDoanhCollection = DataRepository.NhaCungCapNganhNgheKinhDoanhProvider.GetByIDNhaCungCap(transactionManager, entity.IDNhaCungCap);

				if (deep && entity.NhaCungCapNganhNgheKinhDoanhCollection.Count > 0)
				{
					deepHandles.Add("NhaCungCapNganhNgheKinhDoanhCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NhaCungCapNganhNgheKinhDoanh>) DataRepository.NhaCungCapNganhNgheKinhDoanhProvider.DeepLoad,
						new object[] { transactionManager, entity.NhaCungCapNganhNgheKinhDoanhCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<SanPhamDanhMuc>|SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc", deepLoadType, innerList))
			{
				entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc = DataRepository.SanPhamDanhMucProvider.GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(transactionManager, entity.IDNhaCungCap);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc != null)
				{
					deepHandles.Add("SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< SanPhamDanhMuc >) DataRepository.SanPhamDanhMucProvider.DeepLoad,
						new object[] { transactionManager, entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region NguoiDungNhaCungCapCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NguoiDungNhaCungCap>|NguoiDungNhaCungCapCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NguoiDungNhaCungCapCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NguoiDungNhaCungCapCollection = DataRepository.NguoiDungNhaCungCapProvider.GetByIDNhaCungCap(transactionManager, entity.IDNhaCungCap);

				if (deep && entity.NguoiDungNhaCungCapCollection.Count > 0)
				{
					deepHandles.Add("NguoiDungNhaCungCapCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NguoiDungNhaCungCap>) DataRepository.NguoiDungNhaCungCapProvider.DeepLoad,
						new object[] { transactionManager, entity.NguoiDungNhaCungCapCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<NganhNgheKinhDoanh>|NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh", deepLoadType, innerList))
			{
				entity.NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh = DataRepository.NganhNgheKinhDoanhProvider.GetByIDNhaCungCapFromNhaCungCapNganhNgheKinhDoanh(transactionManager, entity.IDNhaCungCap);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh != null)
				{
					deepHandles.Add("NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< NganhNgheKinhDoanh >) DataRepository.NganhNgheKinhDoanhProvider.DeepLoad,
						new object[] { transactionManager, entity.NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region NhaCungCapDiaBanCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NhaCungCapDiaBan>|NhaCungCapDiaBanCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NhaCungCapDiaBanCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NhaCungCapDiaBanCollection = DataRepository.NhaCungCapDiaBanProvider.GetByIDNhaCungCap(transactionManager, entity.IDNhaCungCap);

				if (deep && entity.NhaCungCapDiaBanCollection.Count > 0)
				{
					deepHandles.Add("NhaCungCapDiaBanCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NhaCungCapDiaBan>) DataRepository.NhaCungCapDiaBanProvider.DeepLoad,
						new object[] { transactionManager, entity.NhaCungCapDiaBanCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region DiaBanCollection_From_NhaCungCapDiaBan
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<DiaBan>|DiaBanCollection_From_NhaCungCapDiaBan", deepLoadType, innerList))
			{
				entity.DiaBanCollection_From_NhaCungCapDiaBan = DataRepository.DiaBanProvider.GetByIDNhaCungCapFromNhaCungCapDiaBan(transactionManager, entity.IDNhaCungCap);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'DiaBanCollection_From_NhaCungCapDiaBan' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.DiaBanCollection_From_NhaCungCapDiaBan != null)
				{
					deepHandles.Add("DiaBanCollection_From_NhaCungCapDiaBan",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< DiaBan >) DataRepository.DiaBanProvider.DeepLoad,
						new object[] { transactionManager, entity.DiaBanCollection_From_NhaCungCapDiaBan, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region NguoiDungCollection_From_NguoiDungNhaCungCap
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<NguoiDung>|NguoiDungCollection_From_NguoiDungNhaCungCap", deepLoadType, innerList))
			{
				entity.NguoiDungCollection_From_NguoiDungNhaCungCap = DataRepository.NguoiDungProvider.GetByIDNhaCungCapFromNguoiDungNhaCungCap(transactionManager, entity.IDNhaCungCap);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NguoiDungCollection_From_NguoiDungNhaCungCap' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.NguoiDungCollection_From_NguoiDungNhaCungCap != null)
				{
					deepHandles.Add("NguoiDungCollection_From_NguoiDungNhaCungCap",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< NguoiDung >) DataRepository.NguoiDungProvider.DeepLoad,
						new object[] { transactionManager, entity.NguoiDungCollection_From_NguoiDungNhaCungCap, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the Indeco.G24.Entities.NhaCungCap object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">Indeco.G24.Entities.NhaCungCap instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">Indeco.G24.Entities.NhaCungCap Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		internal override bool DeepSave(TransactionManager transactionManager, Indeco.G24.Entities.NhaCungCap entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<Delegate, object> deepHandles = new Dictionary<Delegate, object>();

			#region NhaCungCapCauHinh
			if (CanDeepSave(entity.NhaCungCapCauHinh, "NhaCungCapCauHinh|NhaCungCapCauHinh", deepSaveType, innerList))
			{

				if (entity.NhaCungCapCauHinh != null)
				{
					// update each child parent id with the real parent id (mostly used on insert)

					entity.NhaCungCapCauHinh.IDNhaCungCap = entity.IDNhaCungCap;
					DataRepository.NhaCungCapCauHinhProvider.Save(transactionManager, entity.NhaCungCapCauHinh);
					deepHandles.Add(
						(DeepSaveSingleHandle< NhaCungCapCauHinh >) DataRepository.NhaCungCapCauHinhProvider.DeepSave,
						new object[] { transactionManager, entity.NhaCungCapCauHinh, deepSaveType, childTypes, innerList }
					);
				}
			} 
			#endregion 

			#region DiaBanCollection_From_NhaCungCapSanPhamDanhMuc>
			if (CanDeepSave(entity.DiaBanCollection_From_NhaCungCapSanPhamDanhMuc, "List<DiaBan>|DiaBanCollection_From_NhaCungCapSanPhamDanhMuc", deepSaveType, innerList))
			{
				if (entity.DiaBanCollection_From_NhaCungCapSanPhamDanhMuc.Count > 0 || entity.DiaBanCollection_From_NhaCungCapSanPhamDanhMuc.DeletedItems.Count > 0)
				{
					DataRepository.DiaBanProvider.Save(transactionManager, entity.DiaBanCollection_From_NhaCungCapSanPhamDanhMuc); 
					deepHandles.Add(
						(DeepSaveHandle<DiaBan>) DataRepository.DiaBanProvider.DeepSave,
						new object[] { transactionManager, entity.DiaBanCollection_From_NhaCungCapSanPhamDanhMuc, deepSaveType, childTypes, innerList }
					);
				}
			}
			#endregion 

			#region SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc>
			if (CanDeepSave(entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc, "List<SanPhamDanhMuc>|SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc", deepSaveType, innerList))
			{
				if (entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc.Count > 0 || entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc.DeletedItems.Count > 0)
				{
					DataRepository.SanPhamDanhMucProvider.Save(transactionManager, entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc); 
					deepHandles.Add(
						(DeepSaveHandle<SanPhamDanhMuc>) DataRepository.SanPhamDanhMucProvider.DeepSave,
						new object[] { transactionManager, entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc, deepSaveType, childTypes, innerList }
					);
				}
			}
			#endregion 

			#region NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh>
			if (CanDeepSave(entity.NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh, "List<NganhNgheKinhDoanh>|NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh", deepSaveType, innerList))
			{
				if (entity.NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh.Count > 0 || entity.NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh.DeletedItems.Count > 0)
				{
					DataRepository.NganhNgheKinhDoanhProvider.Save(transactionManager, entity.NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh); 
					deepHandles.Add(
						(DeepSaveHandle<NganhNgheKinhDoanh>) DataRepository.NganhNgheKinhDoanhProvider.DeepSave,
						new object[] { transactionManager, entity.NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh, deepSaveType, childTypes, innerList }
					);
				}
			}
			#endregion 

			#region DiaBanCollection_From_NhaCungCapDiaBan>
			if (CanDeepSave(entity.DiaBanCollection_From_NhaCungCapDiaBan, "List<DiaBan>|DiaBanCollection_From_NhaCungCapDiaBan", deepSaveType, innerList))
			{
				if (entity.DiaBanCollection_From_NhaCungCapDiaBan.Count > 0 || entity.DiaBanCollection_From_NhaCungCapDiaBan.DeletedItems.Count > 0)
				{
					DataRepository.DiaBanProvider.Save(transactionManager, entity.DiaBanCollection_From_NhaCungCapDiaBan); 
					deepHandles.Add(
						(DeepSaveHandle<DiaBan>) DataRepository.DiaBanProvider.DeepSave,
						new object[] { transactionManager, entity.DiaBanCollection_From_NhaCungCapDiaBan, deepSaveType, childTypes, innerList }
					);
				}
			}
			#endregion 

			#region NguoiDungCollection_From_NguoiDungNhaCungCap>
			if (CanDeepSave(entity.NguoiDungCollection_From_NguoiDungNhaCungCap, "List<NguoiDung>|NguoiDungCollection_From_NguoiDungNhaCungCap", deepSaveType, innerList))
			{
				if (entity.NguoiDungCollection_From_NguoiDungNhaCungCap.Count > 0 || entity.NguoiDungCollection_From_NguoiDungNhaCungCap.DeletedItems.Count > 0)
				{
					DataRepository.NguoiDungProvider.Save(transactionManager, entity.NguoiDungCollection_From_NguoiDungNhaCungCap); 
					deepHandles.Add(
						(DeepSaveHandle<NguoiDung>) DataRepository.NguoiDungProvider.DeepSave,
						new object[] { transactionManager, entity.NguoiDungCollection_From_NguoiDungNhaCungCap, deepSaveType, childTypes, innerList }
					);
				}
			}
			#endregion 
	
			#region List<NhaCungCapSanPhamDanhMuc>
				if (CanDeepSave(entity.NhaCungCapSanPhamDanhMucCollection, "List<NhaCungCapSanPhamDanhMuc>|NhaCungCapSanPhamDanhMucCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NhaCungCapSanPhamDanhMuc child in entity.NhaCungCapSanPhamDanhMucCollection)
					{
						if(child.IDNhaCungCapSource != null)
							child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;
						else
							child.IDNhaCungCap = entity.IDNhaCungCap;

						//Handle right table of DiaBanCollection_From_NhaCungCapSanPhamDanhMuc
						if(child.IDDiaBanSource != null)
						{
								child.IDDiaBan = child.IDDiaBanSource.IDDiaBan;

						}

						//Handle right table of DiaBanCollection_From_NhaCungCapSanPhamDanhMuc
						if(child.IDNhaCungCapSource != null)
						{
								child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;

						}

						//Handle right table of DiaBanCollection_From_NhaCungCapSanPhamDanhMuc
						if(child.IDSanPhamDanhMucSource != null)
						{
								child.IDSanPhamDanhMuc = child.IDSanPhamDanhMucSource.IDSanPhamDanhMuc;

						}

					}

					if (entity.NhaCungCapSanPhamDanhMucCollection.Count > 0 || entity.NhaCungCapSanPhamDanhMucCollection.DeletedItems.Count > 0)
					{
						DataRepository.NhaCungCapSanPhamDanhMucProvider.Save(transactionManager, entity.NhaCungCapSanPhamDanhMucCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< NhaCungCapSanPhamDanhMuc >) DataRepository.NhaCungCapSanPhamDanhMucProvider.DeepSave,
							new object[] { transactionManager, entity.NhaCungCapSanPhamDanhMucCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
	
			#region List<BangGiaSanPham>
				if (CanDeepSave(entity.BangGiaSanPhamCollection, "List<BangGiaSanPham>|BangGiaSanPhamCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(BangGiaSanPham child in entity.BangGiaSanPhamCollection)
					{
						if(child.IDNhaCungCapSource != null)
							child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;
						else
							child.IDNhaCungCap = entity.IDNhaCungCap;

					}

					if (entity.BangGiaSanPhamCollection.Count > 0 || entity.BangGiaSanPhamCollection.DeletedItems.Count > 0)
					{
						DataRepository.BangGiaSanPhamProvider.Save(transactionManager, entity.BangGiaSanPhamCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< BangGiaSanPham >) DataRepository.BangGiaSanPhamProvider.DeepSave,
							new object[] { transactionManager, entity.BangGiaSanPhamCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
	
			#region List<SanPham>
				if (CanDeepSave(entity.SanPhamCollection, "List<SanPham>|SanPhamCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(SanPham child in entity.SanPhamCollection)
					{
						if(child.NhaCungCapSource != null)
							child.NhaCungCap = child.NhaCungCapSource.NhaCungCap;
						else
							child.NhaCungCap = entity.NhaCungCap;

					}

					if (entity.SanPhamCollection.Count > 0 || entity.SanPhamCollection.DeletedItems.Count > 0)
					{
						DataRepository.SanPhamProvider.Save(transactionManager, entity.SanPhamCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< SanPham >) DataRepository.SanPhamProvider.DeepSave,
							new object[] { transactionManager, entity.SanPhamCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
	
			#region List<NhaCungCapLienHe>
				if (CanDeepSave(entity.NhaCungCapLienHeCollection, "List<NhaCungCapLienHe>|NhaCungCapLienHeCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NhaCungCapLienHe child in entity.NhaCungCapLienHeCollection)
					{
						if(child.IDNhaCungCapSource != null)
							child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;
						else
							child.IDNhaCungCap = entity.IDNhaCungCap;

					}

					if (entity.NhaCungCapLienHeCollection.Count > 0 || entity.NhaCungCapLienHeCollection.DeletedItems.Count > 0)
					{
						DataRepository.NhaCungCapLienHeProvider.Save(transactionManager, entity.NhaCungCapLienHeCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< NhaCungCapLienHe >) DataRepository.NhaCungCapLienHeProvider.DeepSave,
							new object[] { transactionManager, entity.NhaCungCapLienHeCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
	
			#region List<NhaCungCapNganhNgheKinhDoanh>
				if (CanDeepSave(entity.NhaCungCapNganhNgheKinhDoanhCollection, "List<NhaCungCapNganhNgheKinhDoanh>|NhaCungCapNganhNgheKinhDoanhCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NhaCungCapNganhNgheKinhDoanh child in entity.NhaCungCapNganhNgheKinhDoanhCollection)
					{
						if(child.IDNhaCungCapSource != null)
							child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;
						else
							child.IDNhaCungCap = entity.IDNhaCungCap;

						//Handle right table of NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh
						if(child.IDNhaCungCapSource != null)
						{
								child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;

						}

						//Handle right table of NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh
						if(child.IDNganhNgheKinhDoanhSource != null)
						{
								child.IDNganhNgheKinhDoanh = child.IDNganhNgheKinhDoanhSource.IDNganhNgheKinhDoanh;

						}

					}

					if (entity.NhaCungCapNganhNgheKinhDoanhCollection.Count > 0 || entity.NhaCungCapNganhNgheKinhDoanhCollection.DeletedItems.Count > 0)
					{
						DataRepository.NhaCungCapNganhNgheKinhDoanhProvider.Save(transactionManager, entity.NhaCungCapNganhNgheKinhDoanhCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< NhaCungCapNganhNgheKinhDoanh >) DataRepository.NhaCungCapNganhNgheKinhDoanhProvider.DeepSave,
							new object[] { transactionManager, entity.NhaCungCapNganhNgheKinhDoanhCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
	
			#region List<NguoiDungNhaCungCap>
				if (CanDeepSave(entity.NguoiDungNhaCungCapCollection, "List<NguoiDungNhaCungCap>|NguoiDungNhaCungCapCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NguoiDungNhaCungCap child in entity.NguoiDungNhaCungCapCollection)
					{
						if(child.IDNhaCungCapSource != null)
							child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;
						else
							child.IDNhaCungCap = entity.IDNhaCungCap;

						//Handle right table of NguoiDungCollection_From_NguoiDungNhaCungCap
						if(child.IDNguoiDungSource != null)
						{
								child.IDNguoiDung = child.IDNguoiDungSource.IDNguoiDung;

						}

						//Handle right table of NguoiDungCollection_From_NguoiDungNhaCungCap
						if(child.IDNhaCungCapSource != null)
						{
								child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;

						}

					}

					if (entity.NguoiDungNhaCungCapCollection.Count > 0 || entity.NguoiDungNhaCungCapCollection.DeletedItems.Count > 0)
					{
						DataRepository.NguoiDungNhaCungCapProvider.Save(transactionManager, entity.NguoiDungNhaCungCapCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< NguoiDungNhaCungCap >) DataRepository.NguoiDungNhaCungCapProvider.DeepSave,
							new object[] { transactionManager, entity.NguoiDungNhaCungCapCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
	
			#region List<NhaCungCapDiaBan>
				if (CanDeepSave(entity.NhaCungCapDiaBanCollection, "List<NhaCungCapDiaBan>|NhaCungCapDiaBanCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NhaCungCapDiaBan child in entity.NhaCungCapDiaBanCollection)
					{
						if(child.IDNhaCungCapSource != null)
							child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;
						else
							child.IDNhaCungCap = entity.IDNhaCungCap;

						//Handle right table of DiaBanCollection_From_NhaCungCapDiaBan
						if(child.IDDiaBanSource != null)
						{
								child.IDDiaBan = child.IDDiaBanSource.IDDiaBan;

						}

						//Handle right table of DiaBanCollection_From_NhaCungCapDiaBan
						if(child.IDNhaCungCapSource != null)
						{
								child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;

						}

					}

					if (entity.NhaCungCapDiaBanCollection.Count > 0 || entity.NhaCungCapDiaBanCollection.DeletedItems.Count > 0)
					{
						DataRepository.NhaCungCapDiaBanProvider.Save(transactionManager, entity.NhaCungCapDiaBanCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< NhaCungCapDiaBan >) DataRepository.NhaCungCapDiaBanProvider.DeepSave,
							new object[] { transactionManager, entity.NhaCungCapDiaBanCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region NhaCungCapChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>Indeco.G24.Entities.NhaCungCap</c>
	///</summary>
	public enum NhaCungCapChildEntityTypes
	{

		///<summary>
		/// Collection of <c>NhaCungCap</c> as OneToMany for NhaCungCapSanPhamDanhMucCollection
		///</summary>
		[ChildEntityType(typeof(TList<NhaCungCapSanPhamDanhMuc>))]
		NhaCungCapSanPhamDanhMucCollection,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as OneToMany for BangGiaSanPhamCollection
		///</summary>
		[ChildEntityType(typeof(TList<BangGiaSanPham>))]
		BangGiaSanPhamCollection,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as OneToMany for SanPhamCollection
		///</summary>
		[ChildEntityType(typeof(TList<SanPham>))]
		SanPhamCollection,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as OneToMany for NhaCungCapLienHeCollection
		///</summary>
		[ChildEntityType(typeof(TList<NhaCungCapLienHe>))]
		NhaCungCapLienHeCollection,
		///<summary>
		/// Entity <c>NhaCungCapCauHinh</c> as OneToOne for NhaCungCapCauHinh
		///</summary>
		[ChildEntityType(typeof(NhaCungCapCauHinh))]
		NhaCungCapCauHinh,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as ManyToMany for DiaBanCollection_From_NhaCungCapSanPhamDanhMuc
		///</summary>
		[ChildEntityType(typeof(TList<DiaBan>))]
		DiaBanCollection_From_NhaCungCapSanPhamDanhMuc,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as OneToMany for NhaCungCapNganhNgheKinhDoanhCollection
		///</summary>
		[ChildEntityType(typeof(TList<NhaCungCapNganhNgheKinhDoanh>))]
		NhaCungCapNganhNgheKinhDoanhCollection,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as ManyToMany for SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc
		///</summary>
		[ChildEntityType(typeof(TList<SanPhamDanhMuc>))]
		SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as OneToMany for NguoiDungNhaCungCapCollection
		///</summary>
		[ChildEntityType(typeof(TList<NguoiDungNhaCungCap>))]
		NguoiDungNhaCungCapCollection,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as ManyToMany for NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh
		///</summary>
		[ChildEntityType(typeof(TList<NganhNgheKinhDoanh>))]
		NganhNgheKinhDoanhCollection_From_NhaCungCapNganhNgheKinhDoanh,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as OneToMany for NhaCungCapDiaBanCollection
		///</summary>
		[ChildEntityType(typeof(TList<NhaCungCapDiaBan>))]
		NhaCungCapDiaBanCollection,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as ManyToMany for DiaBanCollection_From_NhaCungCapDiaBan
		///</summary>
		[ChildEntityType(typeof(TList<DiaBan>))]
		DiaBanCollection_From_NhaCungCapDiaBan,

		///<summary>
		/// Collection of <c>NhaCungCap</c> as ManyToMany for NguoiDungCollection_From_NguoiDungNhaCungCap
		///</summary>
		[ChildEntityType(typeof(TList<NguoiDung>))]
		NguoiDungCollection_From_NguoiDungNhaCungCap,
	}
	
	#endregion NhaCungCapChildEntityTypes
	
	#region NhaCungCapFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;NhaCungCapColumn&gt;"/> class
	/// that is used exclusively with a <see cref="NhaCungCap"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class NhaCungCapFilterBuilder : SqlFilterBuilder<NhaCungCapColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the NhaCungCapFilterBuilder class.
		/// </summary>
		public NhaCungCapFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the NhaCungCapFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public NhaCungCapFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the NhaCungCapFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public NhaCungCapFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion NhaCungCapFilterBuilder
	
	#region NhaCungCapParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;NhaCungCapColumn&gt;"/> class
	/// that is used exclusively with a <see cref="NhaCungCap"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class NhaCungCapParameterBuilder : ParameterizedSqlFilterBuilder<NhaCungCapColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the NhaCungCapParameterBuilder class.
		/// </summary>
		public NhaCungCapParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the NhaCungCapParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public NhaCungCapParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the NhaCungCapParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public NhaCungCapParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion NhaCungCapParameterBuilder
} // end namespace
